﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.OleDb;

namespace WebApplication1
{
    public partial class _Default : System.Web.UI.Page
    {
       
        protected const string connectionString = @"Provider=SQLOLEDB;server=forma1614;Database=magicrecettes;User ID=magicrecettes;Password=cook;Trusted_Connection=False";
        //@"Provider=SQLOLEDB;server=forma1614;Database=magicrecettes;User ID=magicrecettes;Password=cook;Trusted_Connection=False";
        protected const string query = "SELECT * FROM Ingredient";

        protected void Page_Load(object sender, EventArgs e)
        {
            OleDbConnection connection = new OleDbConnection(connectionString);

            OleDbCommand command = new OleDbCommand (query, connection);

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
          
                  
            connection.Open();
            
            
            lblDefault.Text = "OK";
            
            OleDbDataReader dr = command.ExecuteReader();

            sb.Append("Nom, Calories, Unité" + "<br/>");
            if (dr.HasRows)
                while (dr.Read())
                {
                    sb.Append(dr.GetString(1) + " " + dr["Calories"].ToString() + " " + dr["unite"].ToString() + "<br/>");   
                }
            dr.Close();
            pnlDB.Controls.Add(new System.Web.UI.LiteralControl(sb.ToString()));  
        }
    }
}
